<template>
  <div class="hm-attention-item" v-if="Object.keys(attentionInfo).length">
    <div class="left">
      <img :src="attentionInfo.head_img | imgUrl" alt="">
    </div>
    <div class="center">
      <div class="name">{{ attentionInfo.nickname }}</div>
      <div class="time">{{ attentionInfo.create_date | formatDate}}</div>
    </div>
    <div class="right" @click="cancelAttention(attentionInfo.id)">
      取消关注
    </div>
  </div>
</template>

<script>
import moment from 'moment'

export default {
  props: {
    attentionInfo: {
      type: Object,
      default () {
        return {}
      }
    }
  },

  methods: {
    async cancelAttention (id) {
      this.$emit('click', id)
    }
  },

  filters: {
    formatDate (value) {
      const time = +new Date(value)
      return moment(time).format('YYYY-MM-DD')
    }
  }
}
</script>

<style lang="scss" scoped>
.hm-attention-item {
  display: flex;
  padding: 20px;
  align-items: center;
  border-bottom: 1px solid #eee;
  .left {
    img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      margin-right: 20px;
    }
  }
  .center {
    flex: 1;
    .name {
      font-size: 16px;
      color: #000;
    }
    .time {
      font-size: 14px;
    }
  }
  .right {
    width: 70px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    background-color: #eee;
    border-radius: 15px;
  }
}
</style>
